﻿using Newtonsoft;
using Newtonsoft.Json;

namespace 创建者模式
{
    public class ProtoTypeObj : ICloneable
    {
        public int Id { get; set; }

        public string Name { get; set; }

        public HouselInfo HouselInfo { get; set; }

        public object Clone()
        {
            return this.MemberwiseClone();
        }

        //public object Clone()
        //{
        //  var jsonResult = JsonConvert.SerializeObject(this);
        //    return JsonConvert.DeserializeObject<ProtoTypeObj>(jsonResult) ?? new ProtoTypeObj() { };
        //}



        public override string ToString()
        {
            return string.Format("Id:{0},Name:{1},HouselInfo:{2}", Id, Name, HouselInfo.ToString());
        }
    }

    public  class HouselInfo
    {
        public int HouseAge { get; set; }

        public string HouseName { get; set; }

        public string  HouseNo { get; set; }

        public override string ToString()
        {
            return string.Format("HouseAge:{0},HouseName:{1},HouseNo:{2}", HouseAge, HouseName, HouseNo);
        }
    }
}
